<!--
 * @Author: 徐建辰
 * @Date: 2022-06-20 09:02:00
 * @LastEditTime: 2022-06-21 09:03:08
 * @LastEditors: xjc
 * @Description: 上传excel组件
-->
<template>
  <div>
    <input ref="excelUploadRef" class="excel-upload-input" type="file" accept=".xlsx, .xls" @change="handleClick">
    <div class="drop" @drop="handleDrop" @dragover="handleDragover" @dragenter="handleDragover">
      拖拽到此处上传
      <el-button 
        :loading="loading" 
        style="margin-left:16px;" 
        type="primary" 
        icon="el-icon-upload"
        @click="handleUpload"
      >
        点击上传excel
      </el-button>
    </div>
  </div>
</template>

<script setup>
import useUploadExcel from '@/hooks/useUploadExcel'

/* props */
// eslint-disable-next-line no-undef
const props = defineProps({
  beforeUpload: Function,
  onSuccess: Function
})

const {
  excelUploadRef, loading,
  handleClick, handleDragover, handleUpload, handleDrop
} = useUploadExcel(props)
</script>

<style scoped lang="scss">
.excel-upload-input{
  display: none;
  z-index: -9999;
}
.drop{
  border: 2px dashed #bbb;
  width: 600px;
  height: 160px;
  line-height: 160px;
  margin: 0 auto;
  font-size: 24px;
  border-radius: 5px;
  text-align: center;
  color: #bbb;
  position: relative;
}
</style>
